﻿/**
*	Cylinder3D
*	@author 	Liam O'Donnell 2008-04-07
**/

package com.spikything.pants3d.objects {
	
	import com.spikything.pants3d.Pants3D;
	import com.spikything.pants3d.core.Point3D;
	import com.spikything.pants3d.objects.PhysicsSprite3D;
	import flash.display.Sprite;

	public class Cylinder3D extends PhysicsSprite3D {
		
		public var r :Number;
		
		public function Cylinder3D (x:Number=0, y:Number=0, z:Number=0, child:Sprite=null, width:Number=20, height:Number=50, depth:Number=0, weightless:Boolean=false, frictionless:Boolean=false, ghostMode:Boolean=false) {
			super(x, y, z, child, width, height, width, weightless, frictionless, ghostMode);
			r = w/2;
			mass = Math.pow((Math.PI*r), 2) * h;
		}
		
		public override function containsPoint (point:Point3D):Boolean {
			var dx:Number = px - point.px;
			var dy:Number = py - point.py;
			var dz:Number = pz - point.pz;
			var dxz2:Number = (dx*dx) + (dz*dz);
			return (dxz2<=r*r && Math.abs(dy)<=h/2);
		}
		
	}
	
}